import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/oauth/token',
    method: 'post',
    data
  })
}

export function getInfo(data) {
  return request({
    url: '/api/security?access_token='+data,
    method: 'get',
    
    
  })
}

export function logout(data) {
  return request({
    url: '/api/securit',
    method: 'post',
    data
  })
}
// member-controller : 用户管理Show/HideList OperationsExpand Operations
// GET /api/members
// 按搜索条件分页查询

// POST /api/members
// 添加用户

// PATCH /api/members/password/{memberId}
// 用户密码更改

// PATCH /api/members/state/{memberId}
// 用户启用或禁用

// POST /api/members/user_User/{memberId}
// 给用户分配角色

// DELETE /api/members/{memberId}
// 根据用户ID删除用户
//GET /api/members/{memberId}


export function addUser(data) {
  return request({
    url: '/api/members',
    method: 'post',
    data
  })
}
export function updateUser(data) {
  return request({
    url: `/api/members`,
    method: 'patch',
    
    data
  })
}
export function updateUserPwd(id,data) {
  return request({
    url: `/api/members/password/${id}`,
    method: 'patch',
    data
  })
}
// PATCH  /api/members/state/
export function updateUserState(id,data) {
  return request({
    url: `/api/members/state/${id}?state=`+data,
    method: 'patch',
    // data
  })
}
//  /api/members/User_permission/{
  export function updateUserPermission(id, data) {
    return request({
      url: `/api/members/user_role/${id}`,
      method: 'post',
      data
    })
  }
  // DELETE  /api/members/
export function deleteUser(id) {
  return request({
    url: `/api/members/${id}`,
    method: 'delete'
  })
}
export function getUserById(id){
  return request({
    url:`/api/members/${id}`,
    method:'get'
  })
}

export function regiosList(){
  return request({
    url:'/api/regions/all',
    method:"get"
  })
}
export function userList(query) {
  return request({
    url: '/api/members',
    method: 'get',
    params: query
  })
}

// PATCH /api/members/password/{memberId}
export function updatePassword(id,data) {
  return request({
    url: `/api/members/password/${id}?newPassword=`+data,
    method: 'patch',
   
  })
}